<?php

namespace App\Traits\Relation;

use App\Models\Company;
use App\Models\Position;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

trait DepartmentRelation
{
	/**
	 * 获取部门所在公司
	 *
	 * Date: 18/04/2018
	 * @author George
	 * @return BelongsTo
	 */
	public function company()
	{
		return $this->belongsTo(Company::class, 'id', 'company_id');
	}

	/**
	 * 获取部门下的岗位信息
	 *
	 * Date: 18/04/2018
	 * @author George
	 * @return HasMany
	 */
	public function positions()
	{
		return $this->hasMany(Position::class, 'department_id', 'id');
	}
}
